<?PHP

function mysql_date($date='00.00.0000')
{
    $tmp = explode('.', $date);
    return $tmp[2]."-".$tmp[1]."-".$tmp[0];
}

function range_options($current_option="")
{
	$arr = array("1hour:1 час", "3hour:3 часа", "6hour:6 часов", "12hour:12 часов", "24hour:сутки");
	foreach ($arr as $arr_value) {
		list($option, $option_name) = explode(":", $arr_value);
		$selected = ($option == $current_option)?'selected="selected"':'';
		$options .= "<option value=\"$option\" $selected>$option_name</option>";
	}
	return $options;
}

function hours_options($current_option='00:00', $start_hour=0, $end_hour=23)
{
	$selected = ($current_option == 'now')?'selected="selected"':'';
	$options = '<option value="now" $selected>Сейчас</option>';
    for ($i = $start_hour; $i <= $end_hour; $i++) {
		$option = ($i < 10)?"0$i:00":"$i:00";
		$selected = ($option == $current_option)?'selected="selected"':'';
		$options .= "<option value=\"$option\" $selected>$option</option>";
    }
	return $options;	
}

?>